//
//  YWAssetsInventoryRecordHeadTableViewCell.m
//  maintain
//
//  Created by 烟雨云渊 on 16/10/25.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWAssetsInventoryRecordHeadTableViewCell.h"
#import "YWMacro.h"
#import "Masonry.h"
#import "UIColor+CustomColors.h"

#import "YWNewAssetsInventoryHeadModel.h"
#import "YYLabel.h"
#import "YWCommonTool.h"

@interface YWAssetsInventoryRecordHeadTableViewCell()
/*清点人*/
@property (nonatomic, strong) YYLabel * assetsManLabel;
/*位置*/
@property (nonatomic, strong) YYLabel * locationLabel;
/*清点时间*/
@property (nonatomic, strong) YYLabel * assetsTimeLabel;
@end

@implementation YWAssetsInventoryRecordHeadTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpSubviews];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)setAssetInventoryModel:(YWNewAssetsInventoryHeadModel *)assetInventoryModel{
    _assetInventoryModel = assetInventoryModel;
    _assetsManLabel.attributedText = [YWCommonTool attributedTextWithFirstText:@"清点人: " firstColor:[UIColor customTextGrayBlackColor] secondText:_assetInventoryModel.assetsName secondColor:[UIColor customYellowColor] font:kContentFont];
    NSString*locationStr =_assetInventoryModel.location.length?_assetInventoryModel.location:@"无";
    _locationLabel.attributedText = [YWCommonTool attributedTextWithFirstText:@"位置: " firstColor:[UIColor customTextGrayBlackColor] secondText:locationStr secondColor:[UIColor blackColor] font:kContentFont];
    
    self.locationLabel.preferredMaxLayoutWidth = self.locationLabel.frame.size.width;
}

- (void)setUpSubviews{
    [self.assetsManLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.contentView).offset(6);
        make.left.mas_equalTo(self.contentView).offset(8);
        make.right.mas_equalTo(self.contentView).offset(-8);
    }];
    
    [self.locationLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.assetsManLabel.mas_bottom).offset(6);
        make.left.mas_equalTo(self.contentView).offset(8);
        make.right.mas_equalTo(self.contentView).offset(-8);
        make.bottom.mas_equalTo(self.contentView).offset(-8);
    }];
//    [self.assetsTimeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.mas_equalTo(self.locationLabel.mas_bottom).offset(6);
//        make.left.mas_equalTo(self.contentView).offset(8);
//        make.right.mas_equalTo(self.contentView).offset(-8);
//        make.bottom.mas_equalTo(self.contentView).offset(-8);
//    }];
}

//- (void)layoutSubviews{
//    [super layoutSubviews];
//    
//}

- ( YYLabel *)assetsManLabel{
    if (!_assetsManLabel) {
         YYLabel *label = [[ YYLabel alloc] init];
        _assetsManLabel = label;
        [self.contentView addSubview:_assetsManLabel];
    }
    return _assetsManLabel;
}

- ( YYLabel *)locationLabel{
    if (!_locationLabel) {
         YYLabel *label = [[ YYLabel alloc] init];
//        label.font = kContentFont;
        label.numberOfLines = 0;
//        label.textColor = [UIColor customTextGrayBlackColor];
        _locationLabel = label;
        [self.contentView addSubview:_locationLabel];
    }
    return _locationLabel;
}

//- ( YYLabel *)assetsTimeLabel{
//    if (!_assetsTimeLabel) {
//         YYLabel *label = [[ YYLabel alloc] init];
//        label.font = kContentFont;
//        label.textColor = [UIColor customTextGrayBlackColor];
//        _assetsTimeLabel = label;
//        [self.contentView addSubview:_assetsTimeLabel];
//    }
//    return _assetsTimeLabel;
//}

@end
